Global NLoops As Integer, LoopDup As Integer, ListWithFocus As Boolean, Days As Byte
Global sRet As String, Ret As Long, MskErr1 As Boolean, MskErr2 As Boolean
Global DestinDir As String, NoIniArchive As Boolean, bDatedDir As Boolean, bCusDir As Boolean, bUseBoth As Boolean
Global WindowsDir As String, NLoopsTimer As Byte, Interval As Date, IniTime As Date, prevDir As String
Global Default As Boolean, LastBackup As Date, result As Long, Msg As Long, OpenError As Boolean
Global XDir(2) As New Collection, FromPath As String, BaseDir As String, tmpPath As String, newPath As String, bBakNow As Boolean
Public Const Arq = "PCBak.ini"
Public Const SW_SHOW = 5
Declare Function WritePrivateProfileString& Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As String, ByVal lpFileName As String)
Declare Function GetPrivateProfileString& Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String)
Declare Function GetWindowsDirectory& Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long)
Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Public Type NOTIFYICONDATA
cbSize As Long
hwnd As Long
uId As Long
uFlags As Long
uCallBackMessage As Long
hIcon As Long
szTip As String * 64
End Type
Public Const NIM_ADD = &H0
Public Const NIM_MODIFY = &H1
Public Const NIM_DELETE = &H2
Public Const NIF_MESSAGE = &H1
Public Const NIF_ICON = &H2
Public Const NIF_TIP = &H4
Public Const WM_MOUSEMOVE = &H200
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONUP = &H202
Public Const WM_LBUTTONDBLCLK = &H203
Public Const WM_RBUTTONDOWN = &H204
Public Const WM_RBUTTONUP = &H205
Public Const WM_RBUTTONDBLCLK = &H206
Public Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
Public nid As NOTIFYICONDATA
Public Type ListaArqs
Nome As String
Tamanho As Long
End Type
Public Files() As ListaArqs
Private Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type
Option Explicit
'Menu item constants.
Private Const SC_CLOSE As Long = &HF060&
'SetMenuItemInfo fMask constants.
Private Const MIIM_STATE As Long = &H1&
Private Const MIIM_ID As Long = &H2&
'SetMenuItemInfo fState constants.
Private Const MFS_GRAYED As Long = &H3&
Private Const MFS_CHECKED As Long = &H8&
'SendMessage constants.
Private Const WM_NCACTIVATE As Long = &H86
'User-defined Types.
Private Type MENUITEMINFO
cbSize As Long
fMask As Long
fType As Long
fState As Long
wID As Long
hSubMenu As Long
hbmpChecked As Long
hbmpUnchecked As Long
dwItemData As Long
dwTypeData As String
cch As Long
End Type
'Declarations.
Private Declare Function GetSystemMenu Lib "user32" ( _
ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function GetMenuItemInfo Lib "user32" Alias _
"GetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, _
ByVal b As Boolean, lpMenuItemInfo As MENUITEMINFO) As Long
Private Declare Function SetMenuItemInfo Lib "user32" Alias _
"SetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, _
ByVal bool As Boolean, lpcMenuItemInfo As MENUITEMINFO) As Long
Private Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long
'Application-specific constants and variables.
Private Const xSC_CLOSE As Long = -10
Private Const SwapID As Long = 1
Private Const ResetID As Long = 2
Private hMenu As Long
Private MII As MENUITEMINFO
Public Const GW_HWNDPREV = 3
Declare Function OpenIcon Lib "user32" (ByVal hwnd As Long) As Long
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Function ActivatePrevInstance()
Dim OldTitle As String
Dim PrevHndl As Long
Dim result As Long
'Save the title of the application.
OldTitle = App.Title
'Rename the title of this application so
' FindWindow
'will not find this application instance
' .
App.Title = "unwanted instance"
'Attempt to get window handle using VB4
' class name.
PrevHndl = FindWindow("ThunderRTMain", OldTitle)
'Check for no success.
If PrevHndl = 0 Then
'Attempt to get window handle using VB5
' class name.
PrevHndl = FindWindow("ThunderRT5Main", OldTitle)
End If
'Check if found
If PrevHndl = 0 Then
'Attempt to get window handle using VB6
' class name
PrevHndl = FindWindow("ThunderRT6Main", OldTitle)
End If
'Check if found
If PrevHndl = 0 Then
'No previous instance found.
Exit Function
End If
'Get handle to previous window.
PrevHndl = GetWindow(PrevHndl, GW_HWNDPREV)
'Restore the program.
result = OpenIcon(PrevHndl)
'Activate the application.
result = SetForegroundWindow(PrevHndl)
'End the application.
End
End Function
Function SetId(Action As Long) As Long
Dim MenuID As Long
Dim Ret As Long
MenuID = MII.wID
If MII.fState = (MII.fState Or MFS_GRAYED) Then
If Action = SwapID Then
MII.wID = SC_CLOSE
Else
MII.wID = xSC_CLOSE
End If
Else
If Action = SwapID Then
MII.wID = xSC_CLOSE
Else
MII.wID = SC_CLOSE
End If
End If
MII.fMask = MIIM_ID
Ret = SetMenuItemInfo(hMenu, MenuID, False, MII)
If Ret = 0 Then
MII.wID = MenuID
End If
SetId = Ret
End Function
Function Initialize()
On Error GoTo erro
Dim Lenght As Byte
WindowsDir = String(255, 0)
Lenght = GetWindowsDirectory(WindowsDir, 254)
WindowsDir = Left(WindowsDir, Lenght)
If Not Right(WindowsDir, 1) = "\" Then WindowsDir = WindowsDir & "\"